#include "main.h"
#include "CubemapToPanorama.h"

#include <stdio.h>

namespace gd {
	const godot_gdnative_core_api_struct *api = NULL;
}

namespace gdns {
	const godot_gdnative_ext_nativescript_api_struct *api = NULL;
}

void *dummy_constructor(godot_object *p_instance, void *p_method_data) {
	return NULL;
}

void dummy_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data) {
}

void my_gdnative_init(godot_gdnative_init_options *p_options) {
	gd::api = p_options->api_struct;

	// Now find our extensions.
	for (unsigned int i = 0; i < gd::api->num_extensions; i++) {
		switch (gd::api->extensions[i]->type) {
		case GDNATIVE_EXT_NATIVESCRIPT: {
			gdns::api = (godot_gdnative_ext_nativescript_api_struct *)gd::api->extensions[i];
		}; break;
		default: break;
		}
	}
}

void my_gdnative_terminate(godot_gdnative_terminate_options *p_options) {
	gd::api = NULL;
	gdns::api = NULL;
}

void my_nativescript_init(void *p_handle) {
	cubemap_to_panorama_register_methods(p_handle);
}

#ifdef __cplusplus
extern "C" {
#endif

void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) {
	my_gdnative_init(p_options);
}

void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *p_options) {
	my_gdnative_terminate(p_options);
}

void GDN_EXPORT godot_nativescript_init(void *p_handle) {
	my_nativescript_init(p_handle);
}

#ifdef __cplusplus
}
#endif
